package com.cskaoyan.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.stereotype.Component;

/**
 * @author stone
 * @date 2021/11/19 16:13
 */
@Component
public class CustomAdvice implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        long start = System.currentTimeMillis();
        Object proceed = methodInvocation.proceed();
        long end = System.currentTimeMillis();
        System.out.println(methodInvocation.getMethod().getName() + "执行时间为：" + (end - start));

        return proceed;
    }
}
